package com.hgyc.mom.common.config;

import com.hgyc.mom.common.context.FileServiceContext;
import com.hgyc.mom.common.service.FileServiceStrategy;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 文件配置信息
 * @author fwj
 * @since 2025/4/24
 */
@Configuration
public class FileConfig {

    @Bean
    public FileServiceContext fileUploadStrategyContext(
            FileProperties properties,
            FileServiceStrategy localFileServiceStrategy,
            FileServiceStrategy minioFileServiceStrategy) {

        FileServiceStrategy strategy = "minio".equals(properties.getStrategy())
                ? minioFileServiceStrategy
                : localFileServiceStrategy;

        return new FileServiceContext(strategy);
    }

}
